import { PartialType } from '@nestjs/mapped-types'
import { IsEnum, IsNotEmpty, IsNumber, IsOptional } from 'class-validator'
import { Item, ItemStatus } from '../entities/item.entity'

export class CreateItemDto extends PartialType(Item) {
  @IsNotEmpty({ message: '商品名称不能为空' })
  name: string

  @IsOptional()
  description?: string

  @IsNumber({}, { message: '商品价格格式错误' })
  @IsNotEmpty({ message: '价格不能为空' })
  price: number

  @IsNumber({}, { message: '运费格式错误' })
  @IsOptional()
  shippingFee?: number

  @IsNumber({}, { message: '商品原价格格式错误' })
  @IsOptional()
  originalPrice?: number

  @IsEnum(ItemStatus, { message: '商品状态格式错误' })
  @IsOptional()
  status?: ItemStatus
}
